# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=EdisonCore
pkgname=haskell-edisoncore
pkgver=1.3.3
pkgrel=16
pkgdesc="A library of efficient, purely-functional data structures (Core Implementations)"
url="http://rwd.rdockins.name/edison/home/"
license=("MIT")
arch=('loong64' 'x86_64')
depends=('ghc-libs' "haskell-edisonapi" "haskell-quickcheck")
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('a9b22aeec23f9afc2e2399947a26e8358553977cf535c266b5dc8e8b8d99623be46b4294c58bb294c7629a4b0ffe3f70155aeb5adb1e2c2e74518b797010d103')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 "COPYRIGHT" "${pkgdir}/usr/share/licenses/${pkgname}/COPYRIGHT"
    rm -f "${pkgdir}/usr/share/doc/${pkgname}/COPYRIGHT"
}
